package com.thouiot.modbus.util;

import com.serotonin.modbus4j.BasicProcessImage;
import com.serotonin.modbus4j.ModbusSlaveSet;
import com.serotonin.modbus4j.ProcessImage;
import com.serotonin.modbus4j.serial.rtu.RtuSlave;
import com.thouiot.common.exception.TiotRuntimeException;
import com.thouiot.modbus.entity.vo.ModbusLocatorVo;
import com.thouiot.modbus.entity.vo.WriteValueVo;
import com.thouiot.modbus.exception.ModbusErrorCodeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @description modbus slave 工具类
 * @author wangkai
 * @date 2025/04/14 16:48
 */
public class ModbusSlaveUtil {

    private static final Logger log = LoggerFactory.getLogger(ModbusSlaveUtil.class);

    public static void setModbusSlave(ModbusSlaveSet modbusSlaveSet, BasicProcessImage processImage) {
        try {
            modbusSlaveSet.addProcessImage(processImage);
        } catch (Exception e) {
            throw new TiotRuntimeException(ModbusErrorCodeEnum.MODBUS_SLAVE_SET_ERROR);
        }
    }

}
